SESSION 12 - Project on Object Detection - Part II

TOC
PART II

  1. Detection
           5.1 Load an object detection model
           5.2 Check the model's input signature
           5.3 Add a wrapper function to call the model, and cleanup the outputs
           5.4 Run it on each test image and show the results
  2. Instance Segmentation

Setup

The setup has been mentioned in the readme file

2. Install

Make sure you have pycocotools installed

pip install pycocotools

Get tensorflow/models or cd to parent directory of the repository.

Compile protobufs and install the object_detection package

3. Imports

Import the object detection module.

Patches:

4. Model preparation

Variables

Any model exported using the export_inference_graph.py tool can be loaded here simply by changing the path.

By default we use an "SSD with Mobilenet" model here. See the detection model zoo for a list of other models that can be run out-of-the-box with varying speeds and accuracies.

4.1 Loader

4.2 Loading label map

Label maps map indices to category names, so that when our convolution network predicts 5, we know that this corresponds to airplane. Here we use internal utility functions, but anything that returns a dictionary mapping integers to appropriate string labels would be fine

For the sake of simplicity we will test on 2 images:

5. Detection

5.1 Load an object detection model:

5.2 Check the model's input signature, it expects a batch of 3-color images of type uint8:

And retuns several outputs:

5.3 Add a wrapper function to call the model, and cleanup the outputs:

5.4 Run it on each test image and show the results:

6. Instance Segmentation

The instance segmentation model includes a detection_masks output: